<template>
  <div class="department" id="department collapse-itemContent">
    <!-- 左侧部门管理 -->
    <div class="structureTree" v-if="treelength">
      <div class="structureTree_title">
        <div>组织机构</div>
        <div></div>
      </div>
      <tree
        :treeData="treeData"
        :checkData="checkData"
        name="yjSmart-softFoundationManage_treeCheck"
        nodeKey="fCompanyid"
        @getTreeInfo="handleNodeClick"
        :defaultProps="defaultProps"
      >
      </tree>
    </div>
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 机构名称 -->
      <el-breadcrumb :title="showName"></el-breadcrumb>
      <!-- 表格 -->
      <div
        class="warningObject_table tableminute collapse-itemContent"
        id="tableminute collapse-itemContent"
      >
        <el-collapse
          v-if="!pageFlag"
          v-model="activeNames"
          @change="changeCollapse"
        >
          <el-collapse-item name="0">
            <template slot="title">
              <div>
                <img
                  style="vertical-align: middle"
                  src="@/assets/img/Supervision/com_flg.png"
                  alt=""
                />
                <span style="margin-left: 8px"
                  >按每盘混合料单一材料的重量偏差提醒</span
                >
              </div>
            </template>
            <div style="margin-top: 3px; display: flex; flex-direction: column">
              <div>
                <el-table
                  :data="tableData"
                  :span-method="objectSpanMethod"
                  border
                  style="width: 100%"
                >
                  <el-table-column
                    prop="type"
                    label=""
                    align="center"
                    width="180"
                  >
                    <template slot-scope="scope">
                      <el-button
                        :type="
                          scope.row.type == 1
                            ? 'plain'
                            : scope.row.type == 2
                            ? 'warning'
                            : 'danger'
                        "
                        :class="
                          scope.row.type == 1
                            ? 'plain'
                            : scope.row.type == 2
                            ? 'warning'
                            : 'danger'
                        "
                        >{{ scope.row.type | type }}</el-button
                      >
                    </template>
                  </el-table-column>

                  <el-table-column prop="name" label="报警对象" align="center">
                    <template slot-scope="scope">
                      <div class="selectobject">
                        <el-select
                          placeholder="请选择"
                          v-model="scope.row.name"
                          multiple
                          value-key="fId"
                          @change="selectEquipmen(scope.row, scope.row.name)"
                        >
                          <el-option
                            v-for="(item, index) in ObjectsData"
                            :label="`${item.fObjectname}`"
                            :value="item"
                            :key="index"
                          >
                          </el-option>
                        </el-select>
                      </div>
                    </template>
                  </el-table-column>

                  <el-table-column
                    prop="amount1"
                    label="超出多少周期后不发(分钟)"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <div class="inputminute">
                        <el-input
                          v-model="scope.row.amount1"
                          type="number"
                        ></el-input>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="amount2"
                    label="是否启动"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-switch v-model="scope.row.amount2"> </el-switch>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <div style="margin: 5px 0" class="shortMessageform">
                <el-form ref="form" :model="form" label-width="180px">
                  <el-form-item label="短信模板">
                    <el-input type="textarea" v-model="form.desc"></el-input>
                  </el-form-item>
                </el-form>
                <div style="margin-left: 180px; color: #f78989">
                  说明 {0}：表示“标段” {1}：表示“工程名称” {2}：表示“施工层位”
                  {3}：表示“拌和站名称” {4}：表示“拌合机名称”
                  {5}：表示“拌合机编号” {6}：表示“出料时间” {7}：表示“重量”
                  {8}：表示“超标等级” {9}：表示“超标结果”
                </div>
              </div>
              <!-- 保存按钮 -->
              <div class="saveBtn">
                <el-button
                  type="primary"
                  size="small"
                  @click="yj_editObjectForm(0)"
                >
                  保存</el-button
                >
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item name="2">
            <template slot="title">
              <div>
                <img
                  style="vertical-align: middle"
                  src="@/assets/img/Supervision/com_flg.png"
                  alt=""
                />
                <span style="margin-left: 8px"
                  >按照一段时间内不合格的盘数提醒</span
                >
              </div>
            </template>
            <div style="margin-top: 3px">
              <div class="customTableTotal">
                <el-table :data="tableData2" style="width: 100%">
                  <el-table-column
                    prop="fSendobject"
                    label="发送对象"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <div class="selectobject">
                        <el-select
                          placeholder="请选择"
                          v-model="scope.row.fSendobject"
                          value-key="fId"
                          @change="
                            selectEquipmen(scope.row, scope.row.fSendobject)
                          "
                        >
                          <el-option
                            v-for="(item, index) in ObjectsData"
                            :label="`${item.fObjectname}`"
                            :value="item"
                            :key="index"
                          >
                          </el-option>
                        </el-select>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="fSendperiod"
                    label="发送周期(0~59分钟)"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <div class="inputminute">
                        <el-input
                          @input="minuteScope($event, scope)"
                          v-model="scope.row.fSendperiod"
                          type="number"
                          min="0"
                          max="59"
                        ></el-input>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="fUnqualifiedcount"
                    label="不合格盘数"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <div class="inputminute">
                        <el-input
                          v-model="scope.row.fUnqualifiedcount"
                        ></el-input>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="fIsstarted"
                    label="是否启动"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-switch v-model="scope.row.fIsstarted"> </el-switch>
                    </template>
                  </el-table-column>
                  <el-table-column align="right">
                    <template slot="header">
                      <div class="customTable">
                        <el-button
                          type="primary"
                          icon="el-icon-circle-plus-outline"
                          @click="addUnqualifiedInfo"
                        ></el-button>
                      </div>
                    </template>
                    <template slot-scope="scope">
                      <div class="customTable" style="padding-right: 37px">
                        <el-button
                          type="danger"
                          icon="el-icon-delete"
                          @click="
                            deleteUnqualifiedInfo(scope.$index, scope.row)
                          "
                          circle
                        ></el-button>
                      </div>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <div style="margin: 5px 0" class="shortMessageform">
                <el-form ref="form" :model="form2" label-width="180px">
                  <el-form-item label="短信模板">
                    <el-input type="textarea" v-model="form2.desc"></el-input>
                  </el-form-item>
                </el-form>
              </div>
              <div style="margin-left: 180px; color: #f78989">
                说明 {0}：表示“标段” {1}：表示“拌合机名称” {2}：表示“发送周期”
                {3}：表示“超标盘数” {4}：表示“最近出料时间”
              </div>
              <!-- 保存按钮 -->
              <div class="saveBtn">
                <el-button
                  type="primary"
                  size="small"
                  @click="yj_editObjectForm(2)"
                >
                  保存</el-button
                >
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item name="3">
            <template slot="title">
              <div>
                <img
                  style="vertical-align: middle"
                  src="@/assets/img/Supervision/com_flg.png"
                  alt=""
                />
                <span style="margin-left: 8px">昨日不合格总量进行提醒</span>
              </div>
            </template>
            <div style="margin-top: 3px">
              <div>
                <el-table :data="tableData1" border style="width: 100%">
                  <el-table-column prop="name" label="报警对象" align="center">
                    <template slot-scope="scope">
                      <div class="selectobject">
                        <el-select
                          placeholder="请选择"
                          v-model="scope.row.name"
                          multiple
                          value-key="fId"
                          @change="selectEquipmen(scope.row, scope.row.name)"
                        >
                          <el-option
                            v-for="(item, index) in ObjectsData"
                            :label="`${item.fObjectname}`"
                            :value="item"
                            :key="index"
                          >
                          </el-option>
                        </el-select>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="amount1"
                    label="发送时间(有效范围0-23)"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <div class="inputminute">
                        <el-input
                          @input="timeScope"
                          v-model="scope.row.amount1"
                          type="number"
                          min="0"
                          max="23"
                        ></el-input>
                      </div>
                    </template>
                  </el-table-column>
                  <el-table-column
                    prop="amount2"
                    label="是否启动"
                    align="center"
                  >
                    <template slot-scope="scope">
                      <el-switch v-model="scope.row.amount2"> </el-switch>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
              <div style="margin: 5px 0" class="shortMessageform">
                <el-form ref="form" :model="form1" label-width="180px">
                  <el-form-item label="短信模板">
                    <el-input type="textarea" v-model="form1.desc"></el-input>
                  </el-form-item>
                </el-form>
              </div>
              <div style="margin-left: 180px; color: #f78989">
                说明 {0}：表示“标段” {1}：表示“拌合机编号”
                {2}：表示“昨日累计盘数” {3}：表示“昨日累计超标盘数”
                {4}：表示“代表总方量” {5}：表示“超标方量” {6}：表示“超标率”
              </div>
              <!-- 保存按钮 -->
              <div class="saveBtn">
                <el-button
                  type="primary"
                  size="small"
                  @click="yj_editObjectForm(3)"
                >
                  保存</el-button
                >
              </div>
            </div>
          </el-collapse-item>
        </el-collapse>
        <div v-if="pageFlag" class="pageFlag">
          <img src="@/assets/img/undata.png" alt="" />
          <div class="pageFlagText">暂时没有数据哦！</div>
          <div class="pageFlagTexts">请选择施工单位</div>
        </div>
      </div>
    </div>
  </div>
</template>
<script src="./index.js"></script>
    
<style scoped lang="less">
@import "./index.less";
</style>